package me.zhengjie.util;


import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;


public final class TimeUtil {

    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    public static ZonedDateTime convertToZonedDateTime(String timeString){
        LocalDateTime localDateTime = LocalDateTime.parse(timeString.substring(0, "yyyyMMdd_HHmmss".length()), DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("GMT", ZoneId.SHORT_IDS));
        return zonedDateTime;
    }

    public static String convertZonedDateTimeToString(ZonedDateTime zonedDateTime){
        return zonedDateTime.format(formatter);
    }
}
